/**
 * 
 */
package com.lu.web.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.lu.dto.LogDto;
import com.lu.service.ILogService;

/**
 * 
 * 日志控制器
 * 
 * @author lusm
 *
 * @Date 2016年5月1日
 */
@Controller
@RequestMapping("log")
public class LogController {
	@Resource
	private ILogService logService;
	private Logger logger = Logger.getLogger(LogController.class);

	@RequestMapping("/list.html")
	public String gotoQuery() {
		return "log/logList";
	}

	@RequestMapping("/querylist")
	@ResponseBody
	public Map<String, Object> queryLogList(int page, int rows) {
		List<LogDto> logs = null;
		try {
			logs = logService.getLogList(page, rows);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error(e.getMessage(), e);
		}
		PageInfo<LogDto> logPage = new PageInfo<LogDto>(logs);
		Map<String, Object> result = new HashMap<String, Object>();
		result.put("total", logPage.getTotal());
		result.put("rows", logs);
		return result;
	}
}
